# examples/F90 include file for CMake

set -eax
echo "Script: $0"

proj_dir=@PROJECT_SOURCE_DIR@
data_dir=@PROJECT_BINARY_DIR@/data
HAVE_PRODUCT_BUFR=@HAVE_PRODUCT_BUFR@
HAVE_PRODUCT_GRIB=@HAVE_PRODUCT_GRIB@
HAVE_MEMFS=@HAVE_MEMFS@

# use definitions from binary dir to test if installation will be correct
def_dir="@CMAKE_BINARY_DIR@/@ECCODES_DEFINITION_SUFF@"
ECCODES_DEFINITION_PATH="${def_dir}"
export ECCODES_DEFINITION_PATH

tools_dir=@CMAKE_BINARY_DIR@/bin
examples_dir=@CMAKE_CURRENT_BINARY_DIR@

# If this environment variable is set, then run the
# executables with valgrind
if test "x$ECCODES_TEST_WITH_VALGRIND" != "x"; then
   tools_dir="valgrind --error-exitcode=1 -q $tools_dir"
   examples_dir="valgrind --error-exitcode=1 -q $examples_dir"
fi

# use samples from binary dir to test if installation will be correct
samp_dir="@CMAKE_BINARY_DIR@/@ECCODES_SAMPLES_SUFF@"
ECCODES_SAMPLES_PATH=${samp_dir}
export ECCODES_SAMPLES_PATH

if [ $HAVE_MEMFS -eq 1 ]; then
   unset ECCODES_DEFINITION_PATH
fi
